﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Collections;
using System.IO;

namespace Distrackting.Parser
{
    public class Waypoint
    {
        string name, tempo;
        double lat;
        double lon;
        double ele;

        public Waypoint()
        {
            name = "?";
            tempo = "?";
            lat = 0.0;
            lon = 0.0;
            ele = 0.0;
        }

        public Waypoint(double la, double lo)
        {
            lat = la;
            lon = lo;
            name = "?";
            tempo = "?";
            ele = 0.0;
        }

        public string getName() { return name; }
        public double getLat() { return lat; }
        public double getLon() { return lon; }
        public double getEle() { return ele; }

        public void setName(string nam) { name = nam; }
        public void setTime(string t) { tempo = t; }
        public void setEle(double el) { ele = el; }

        public void printWpt(StreamWriter tw)
        {
            try
            {
                tw.WriteLine("      <wpt lat=\"" + lat + "\" lon=\"" + lon + "\">");
                if (!name.Equals("?")) tw.WriteLine("        <name>" + name + "</name>");
                if (!tempo.Equals("?")) tw.WriteLine("        <time>" + tempo + "</time>");
                if (ele != 0.0) tw.WriteLine("        <ele>" + ele + "</ele>");
                tw.WriteLine("      </wpt>");

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "Cannot open file.");
                throw e;
            }
        }
    }
}
